// CSE571 - async-io-svc-handler.cpp
// Authors: Jonathan Wald, Daniel Sarfati, Guangle Fan
// Async service handler which inherits from ACE_Svc_Handler
// and is home to shared functionality for Dealer and Player
// service handlers.

#ifndef ASYNC_IO_SVC_HANDLER_H
#define ASYNC_IO_SVC_HANDLER_H

#include "ace/Reactor.h"
#include "ace/Svc_Handler.h"
#include "ace/Acceptor.h"
#include "ace/Synch.h"
#include "ace/SOCK_Acceptor.h"

#include "dealer.h"

class Player;

#define PORT_NUM 10101
#define DATA_SIZE 100

using namespace std;

class ACE_Message_Block;

class AsyncIOSvcHandler:
public ACE_Svc_Handler<ACE_SOCK_STREAM,ACE_NULL_SYNCH> {

 public:
  virtual int handle_completed_read(string data);
  virtual int enqueue_string_for_output(string s);
  virtual int enqueue_card_for_output(char s, char r);
  virtual bool ready_for_read() { return true; };
  virtual bool delete_if_necessary() {return false; };
  virtual bool suspended(ACE_Message_Block*) { return true; };
  virtual bool last_act() { return false; };
  bool sent_act;
  bool counterpart_quit;

  ACE_Message_Block* resume_block;
  ACE_Message_Block* suspend_block;
  ACE_Message_Block* first_resume; 
};

#endif
